var express = require('express');
var router = express.Router();

/* GET home page. */

var books=[
{name:"走遍万水千山",author:"三毛",price:32},
{name:"白夜行",author:"东野圭吾",price:30},
{name:"梦里花落知多少",author:"三毛",price:40},
{name:"亲爱的宝贝",author:"三毛",price:23},
{name:"钢铁是怎样练成的",author:"保尔",price:43},
{name:"背影",author:"朱自清",price:39}
];



router.get('/', function(req, res, next) {
  res.render('index', 
  	{ title: '休闲图书馆',
  		books:books
  	}
  	);
});


router.get('/editbookView',function(req, res, next){
	res.render('user_edit',{});
	})



router.post('/addbook',function(req, res, next){
		books.push({
		name:req.body.bname,
		author:req.body.bauthor,
		price:req.body.bprice
		});
	res.redirect('/');//页面跳转
	})
//router.get('/game',function(req,res,next){
	//res.send("<h1>这是我的游戏界面</h1>");
	//});
module.exports = router;
